package sg.nus.iss.vmcs.utils;

import java.text.NumberFormat;

/**
 * Utility Method for formatting money<br><br>
 * Modifications:
 * <li>Philip - 28/12/2010 - Refactored method</li>
 * <br><br>
 * @author Pang Pingli
 * @author Philip Chew
 */
public class MoneyFormatter {
	
	/**
	 * Formats cents into money with a prefixed $ symbol if more than 1 dollar
	 * Amounts less than 1 dollar are returned with the C symbol suffix
	 * @param amount
	 * @return
	 */
	public static String toMoney(int amount) {
		if(amount < 100) {
			return amount + "C";
		}
		else {
			NumberFormat nf = NumberFormat.getCurrencyInstance();
			return nf.format((float)amount / 100);
		}
	}
}